<%-- 
    Document   : editcareCustomer
    Created on : Jul 6, 2012, 4:45:32 PM
    Author     : VANANH
--%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="../css/popup.css"/>
        <link rel="stylesheet" type="text/css" href="../css/kapiform.css"/>
        <script type="text/javascript" language="javascript" src="../scripts/jQuery/jq.date.js"></script>  
        <link rel="stylesheet" type="text/css" href="../css/ui.datepicker.css"/>
    </head>
    <script type="text/javascript">
        var open_cur = 0;
        $j = jQuery.noConflict();
        $j(document).ready(function(){

           
            validateform("form-input-customer");
        });

    </script>
    <script type="text/javascript">
        var open_cur = 0;
        $j = jQuery.noConflict();
        $j(document).ready(function(){      
            $j('input#to,input#from').datepicker({ dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '../images/calenda_icon.gif', buttonImageOnly: true }); 
            $j('input#dateN550').datepicker({ dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '../images/calenda_icon.gif', buttonImageOnly: true }); 
            $j('.getdate').live('change',function(){
                dateForm =  $j(this).val();
                //  alert(dateForm);
                if(dateForm != null){
                    $j.post("actiongetdateforTour.jsp?action=getdate&dateTT="+dateForm, function(data){
                          
                    });
                }
            });
            $j('.numberdate').bind('blur',function(){
                
            
                var songaydi=$j(this).val();
                numbergo = parseInt(songaydi);
                ngaydi = $j(this).parent().parent().parent().prev().children().children().next().val();
                day = ngaydi.substr(0, 2);
                mont = ngaydi.substr(3,2);
                yyy = ngaydi.substr(6,4);
                
                dateghep = mont+"/"+day+"/"+yyy;
                var dateobj= new Date(dateghep); 
                dateobj.setDate(dateobj.getDate()+ numbergo );
                var montha1= dateobj.getMonth() +1;
                var dayaaa1 = dateobj.getDate() -1;
                var yeara1 = dateobj.getFullYear();
               
                intdate = dayaaa1 + "/" + montha1 + "/" + yeara1;
                $j(this).parent().parent().parent().prev().children().next().children().next().children().val(intdate);          
            });
                
            
            $j('.getdate1').live('change',function(){
                dateForm =  $j(this).val();
               
                day = dateForm.substr(0, 2);
                mont = dateForm.substr(3,2);
                yyy = dateForm.substr(6,4);
                datetotal = mont +"/"+day+"/"+yyy;

                //alert(datetotal);
                dateTo = $j(this).parent().parent().prev().children().next().val();
              
                day1 = dateTo.substr(0, 2);
                mont1 = dateTo.substr(3,2);
                yyy1 = dateTo.substr(6,4);
                datetotal1 = mont1 +"/"+day1+"/"+yyy1;
             
                dayssss =daydiff(parseDate(datetotal1), parseDate(datetotal)); 
                $j(this).parent().parent().parent().next().children().children().next().children().next().val(dayssss);
               
            });
            
            function parseDate(str) {
                // str = "12/12/2013";
                var mdy = str.split('/')
                return new Date(mdy[2], mdy[0]-1, mdy[1]);
            }

            function daydiff(first, second) {
                return (second-first)/(1000*60*60*24)
            }

            //  alert(daydiff(parseDate("12/12/2012")), parseDate("12/12/2013")));

              
            $j('.hideTP').live('change',function(){
                if($j('.hideTP').is(':checked')){
                    $j(this).parent().prev().children().next().val("");
                    $j(this).next().next().css("display","block");
                }else{
                    $j(this).next().next().css("display","none");
                }
            });
            
            $j('.cbbcountry').live('change',function(){	
                if($j('.hideTP').is(':checked')){
                     
                }else{
                    var text= $j(this).find("option:selected").text();
                    // alert($j(this).parent().prev().children().next().attr('class'));
                    if($j(this).parent().prev().children().next().val() != ""){
                        text =  $j(this).parent().prev().children().next().val() + " - "+text ;
                    }else{
                        text =  $j(this).parent().prev().children().next().val() +text ;
                    }
                
                    $j(this).parent().prev().children().next().val(text);  
                }
                
            
             
               
            });
            
            $j('.cbbcity').live('change',function(){	
                var text= $j(this).find("option:selected").text();
                // alert($j(this).parent().prev().children().next().attr('class'));
                if($j(this).parent().parent().prev().children().next().val() != ""){
                    text =  $j(this).parent().parent().prev().children().next().val() + " - "+text ;
                }else{
                    text =  $j(this).parent().parent().prev().children().next().val() +text ;
                }
                
                $j(this).parent().parent().prev().children().next().val(text);
            
             
               
            });
        });
    </script>
    <style type="text/css">
        #ui-datepicker-div
        {
            z-index: 9999999;
        }

        .field_normal{            
            width:100%; 
        }
        .field_pink{
            background-color: #D1E1F1; 

        }
        .form_item_content{
            margin-left: 0px !important;
        }

        .label{
            margin-left: 10px !important;
            text-align: right;
            width: 80px !important;; 
        }
        .main_content{
            height: 190px !important;
        }
        .fields_input{
            margin-top: 10px !important;
        }
        .label123{
            width: 100px !important;
        }
        .popup-content .main_content .form_item_content .fields_input input[type="text"]{
            width: 89px;
        }
        .cbx_a000{
            float:left;
            width: 151px;
        }
        .popup-content .main_content .form_item_content .fields_input select{
            margin-left: 4px !important;
        }
        .hideforTour{
            display: none;
        }
        .select_cus td label{
            width: 50px !important;
        }
    </style>
    <f:view>
        <h:form id="form-input-customer" >
            <body style=" float:left; width:auto; height:auto; margin:0px;">
                <f:loadBundle basename="#{environmentSession.localizationSource}" var="locale"/>

                <div class="popup" style="height:421px;; width:454px">
                    <div class="popup-header">
                        <div class="title"><h:outputText value="#{locale.tourTitle}"/></div>
                    </div>
                    <div class="popup-content">
                        <div class="main_content">
                            <div class="form_item_content" style="margin-top: 0px !important;margin-bottom: 20px;" >
                                <div class="item_content" style="display:block">
                                    <div  class="field_normal" style="height:30px; margin-top: 6px">
                                        <div class="fields_input">
                                            <label class="label label123" ><h:outputText value="#{locale.nameTour}"/>:* </label>
                                            <h:inputText value="#{v050Controller.vv052}"  style=" width:290px;"  ></h:inputText>
                                        </div>

                                        <div class="fields_input" style="margin-left: 117px;">
                                            <h:selectBooleanCheckbox styleClass="hideTP" style="float:left;" value=""></h:selectBooleanCheckbox>
                                            <h:selectOneMenu style="float:left;" value="#{SPBean.idcountry}" id="countryinput"  styleClass="cbx_a000 cbbcountry">  
                                                <f:selectItems value="#{SPBean.combN750TP}" />  
                                                <a4j:support event="onchange"  actionListener="#{SPBean.changeCountryTP}" reRender="targetinput" />
                                            </h:selectOneMenu>
                                            <div class="hideforTour">
                                                <h:selectOneMenu style="float:left;width:133px;" value="#{SPBean.pnFA000T}" id="targetinput" styleClass="cbx_a000 cbbcity">  
                                                    <f:selectItems  value="#{SPBean.cbxA000TTP}" />  

                                                </h:selectOneMenu> 
                                            </div>
                                        </div>

                                        <div class="fields_input field_pink">
                                            <label style="width:105px;" > </label>
                                            <h:selectOneRadio value="#{v050Controller.vn079}" styleClass="select_cus" id="select_cus_ck" style="width:227px;">
                                                <f:selectItem itemLabel="INB" itemValue="0"/>
                                                <f:selectItem itemLabel="OUT" itemValue="1"/>
                                                
                                            </h:selectOneRadio>
                                        </div>
                                    </div>
                                    <div class="field_normal" style="height:25px; " >
                                        
                                        <div class="fields_input" >
                                             <label style="width:105px;" >Quy trình VISA: </label>
                                           <h:selectOneMenu value="#{v050Controller.fc475}">
                                                <f:selectItem itemLabel="-----------" itemValue="0"/>
                                                <f:selectItems value="#{v050Controller.cbbFC475}"/>    
                                            </h:selectOneMenu>
                                        </div>  
                                         <div class="fields_input" >
                                             <label style="width:105px;" >Sản phẩm Tour: </label>
                                             <h:selectOneMenu value="#{v050Controller.fs400}">
                                                <f:selectItems value="#{v050Controller.cbbFS400}"/>    
                                            </h:selectOneMenu>
                                        </div>  
                                        <div class="fields_input" >    
                                            <div>    
                                                <label class="lbl_editWork" style="width:110px !important;"><h:outputText value="Ngày đi"/>:</label>
                                                <input type="text" id="to" name="to"  class="input_fields required date getdate"  
                                                       value="<h:outputText value="#{v050Controller.vd074}">
                                                           <f:convertDateTime pattern="dd/MM/yyyy"/>
                                                       </h:outputText>"/>
                                            </div>
                                            <div>
                                                <label class="lbl_editWork" style="width:82px !important;"><h:outputText value="Ngày về"/>:</label>
                                                <h:panelGroup id="dateto"  >  <input type="text" id="from" name="from"  class="input_fields required date getdate1"  
                                                       value="<h:outputText value="#{v050Controller.vd073}"> <f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>"/>
                                                </h:panelGroup>
                                            </div>
                                        </div>
                                        <div  class="field_normal" style="height:25px; margin-top: 2px">
                                            <div style="float: left;width: 51%;background-color: #D1E1F1;height: 45px;margin-top: 8px;">
                                                <div class="fields_input" style="margin-top: 4px;">
                                                    <label class="label" style="width:100px !important;"><h:outputText value="Số người"/>: </label>
                                                    <h:inputText value="#{v050Controller.vn053}"  style="width:89px;text-align:right;  " styleClass="required number" ></h:inputText>
                                                </div>
                                            </div>
                                            <div style="float: left;width: 49%;background-color: #D1E1F1;height: 45px;margin-top: 8px;">
                                                <div class="fields_input" style="margin-top: 4px;">
                                                    <label class="label"style="width: 49px !important;"><h:outputText value="Giá"/>: </label>
                                                    <h:inputText value="#{v050Controller.vn055}"  style="width:108px;text-align:right; " styleClass="required number" ></h:inputText>
                                                </div>
                                            </div>
                                        </div>
                                        <div style="float: left;">
                                            <div class="fields_input" style="margin-top: 4px;margin-bottom: 10px;">
                                                <label class="label"style="width: 68px !important;margin-left: 41px !important"><h:outputText value="Ghi chú"/>: </label>
                                                <h:inputTextarea style="width:289px;height:50px" value="#{v050Controller.vv071}"/>
                                            </div>

                                        </div>
                                    </div>

                                </div>

                                <div class="popup-footer">
                                    <div class="buttonsave" style="margin-right: 33px;"  onclick="parent.jQuery.fancybox.close(); "  ><span><h:outputText value="#{locale.close}"/></span></div>
                                    <h:commandButton   onclick="return validatecheck('form-input-customer');"  action="#{v050Controller.stdv_tools_inserttabv050new}" value="#{locale.save}" styleClass="buttonsave">

                                    </h:commandButton>
                                </div>

                            </div>
                            </body>
                        </h:form>
                    </f:view>
                    </html>
                    <script type="text/javascript">
                        $j(document).ready(function(){
                            yhight = ($j('.popup').height()-90)+"px" ;
                            $j('.main_content').css('height',yhight );
                            $j('.popup-content').css('height',yhight );
                        });
                    </script>